package com.junxonline.instant.dao.entity.model.config;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.junxonline.instant.common.entity.common.CommonEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 系统菜单表实体类
 *
 * @author JunX
 * @date 2021-06-30
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "sys_menu")
public class Menu extends CommonEntity {

    /**
     * ID
     */
    @TableId(type = IdType.AUTO)
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long id;

    /**
     * 名称
     */
    @TableField(value = "name")
    private String name;

    /**
     * 菜单标识
     */
    @TableField(value = "`code`")
    private String code;

    /**
     * 类型
     */
    @TableField(value = "type")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer type;

    /**
     * 组件路径
     */
    @TableField(value = "component")
    private String component;

    /**
     * 是否隐藏
     */
    @TableField(value = "invisible")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer invisible;

    /**
     * 不可关闭
     */
    @TableField(value = "closable")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer closable;

    /**
     * 路由地址
     */
    @TableField(value = "path")
    private String path;

    /**
     * 权限标识
     */
    @TableField(value = "permission")
    private String permission;

    /**
     * 外链地址
     */
    @TableField(value = "href")
    private String href;

    /**
     * 外链地址(新窗口)
     */
    @TableField(value = "link")
    private String link;

    /**
     * 图标
     */
    @TableField(value = "icon")
    private String icon;

    /**
     * 排序
     */
    @TableField(value = "sort")
    private Integer sort;

    /**
     * 上级菜单ID
     */
    @TableField(value = "parent_id")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long parentId;

    /**
     * 是否系统菜单
     */
    @TableField(value = "is_system")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer isSystem;

    /**
     * 状态
     */
    @TableField(value = "status")
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer status;

    /**
     * 子菜单集合
     */
    @TableField(exist = false)
    private List<Menu> children;

    /**
     * 上级菜单名称
     */
    @TableField(exist = false)
    private String parentName;

}
